package homework;

import java.util.Random;

public class Homework5 {

	public static void main(String[] args) {
		int[] array = new int[4];
		Random rand = new Random();
		for(int i = 0; i < 4; i++){
			label:
			for (int k = 0; ; k++) {
				int number = rand.nextInt(10);
				for (int j = 0; j < 4; j++) {
					if(0 == number){
						if(0 == i){
							array[i] = number;
							break label;
						}else if(1 == i){
							if(array[0] != 0){
								array[i] = number;
								break label;
							}
						}else if(2 == i){
							if(array[0] != 0 && array[1] != 0){
								array[i] = number;
								break label;
							}
						}else if(3 == i){
							if(array[0] != 0 && array[1] != 0 && array[2] != 0){
								array[i] = number;
								break label;
							}
						}
					}else if (number == array[j]) {
						continue label;
					}
				}
				array[i] = number;
				break;
			}
		}
		
		for(int i : array){
			System.out.print(i+" ");
		}
	}

}
